#!/bin/sh
# SPDX-License-Identifier: LGPL-2.1+

set -eu
[ -n "${DEBUG:-}" ] && set -x

PASS=0
UUID=$(uuidgen)

cleanup() {
    [ "$PASS" = "1" ] || (echo FAIL && exit 1)
}

LXCFSDIR=${LXCFSDIR:-/var/lib/lxcfs}

trap cleanup EXIT HUP INT TERM

if ! mountpoint -q ${LXCFSDIR}; then
    echo "lxcfs isn't mounted on ${LXCFSDIR}"
    exit 1
fi

TESTCASE="Stress readdir"
echo "==> Checking for cpuset cgroups"
if [ -d /sys/fs/cgroup/cpuset ]; then
   for i in `seq 1 1000`;do ls -al "${LXCFSDIR}/cgroup/cpuset" >/dev/null; done
else
   echo "==> Skipping $TESTCASE"
fi

PASS=1
